<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>加班</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no,email=no" />
		<link rel="stylesheet" href="../css/mui.min.css">			
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/OA.css" />
		
	</head>
	<body>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<script src="../js/app.js"></script>
		<script type="text/javascript" charset="utf-8">
			 //mui初始化
			mui.init();
					
		</script>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">加班</h1>
		</header>
		<div class="mui-content transparent">
			<div class="space-line"></div>
			<div class="mui-input-group" id="nomarlReg">
				<div class="mui-input-row ">
					<span class='mui-navigate-right'></span>
					<label>加班类型</label>
					<select id='type'  >
						<option>周末加班</option>
						<option>晚上加班</option>
						<option>节假日加班</option>
					</select>
				</div>
			</div>
			<div class="space-line"></div>
			<div class="mui-input-group" id="nomarlReg">
				
				<div class="mui-input-row">
					<span class='mui-navigate-right'></span>
					<label>开始时间</label>  
					<input id='startTime' type="datetime-local" class="mui-input-clear " placeholder="请选择开始时间">
				</div>
				<div class="mui-input-row ">
					<span class='mui-navigate-right'></span>
					<label>结束时间</label>
					<input id='endTime' type="datetime-local" class="mui-input-clear " placeholder="">
				</div>
			</div>
			<div class="space-line"></div>
			<div class="mui-input-group" id="nomarlReg">
				<div class="mui-input-row ">
					<label>加班原因</label>
					<textarea id='reason'  class="mui-input-clear mui-input" placeholder="请填写加班原因."></textarea>
				</div>
							
			</div>
			<div class="submit"> 
				<button id="submit" type="button" class="mui-btn mui-btn-primary mui-btn-block">提交</button>
			</div>
		</div>
		
		<script>
			var type=document.getElementById('type');
			var startTime=document.getElementById('startTime');
			var endTime=document.getElementById('endTime');
			var reason=document.getElementById('reason');
			var submit=document.getElementById('submit')
			//提交
			mui.plusReady(function() { 
				mui.ajax(url+'OA/GetExamineOverTimeType',{
							dataType:'json',
							data:{ 
								webToken:'rqlh',
								userId:549
							},
							timeout:10000,
							success:function(data){
								var dataLen=data.Data.length;
								var row='';
								console.log(startTime.value); 
								console.log(data.Code); 
								console.log(data.Msg); 
								if(data.Code=="000"){
									for(var i = 0; i < dataLen; i++){
										row +='<option value='+data.Data[i].TypeId+'>'+data.Data[i].TypeName+'</option>'
									}
									type.innerHTML=row;
								}else{
//									plus.nativeUI.toast("网络连接失败");
								} 
							},
							error:function(xhr,type,errorThrown){
								plus.nativeUI.toast("网络连接失败");
								console.log(data.Msg);   
							}
				})
				submit.addEventListener("tap",function(){
					console.log(startTime.value);
					//验证
					if(!isEmpty(startTime.value)){
						mui.toast('开始时间不能为空');
						return;
					}
					if(!isEmpty(endTime.value)){
						mui.toast('结束时间不能为空');
						return;
					}
					if(!isEmpty(reason.value)){
						mui.toast('加班原因不能为空');
						return;
					}
					console.log("aaa"+type.value);
					mui.ajax(url+'OA/PostExamineOverTime',{
								dataType:'json',
								type:'post',
								data:{
										userId:'549', 
										typeId: type.value,
										beginDate: startTime.value,
										endDate: endTime.value, 
										msg: reason.value,
										webToken:'rqlh' 
										},
								timeout:10000,
								success:function(data){
									console.log(startTime.value); 
									console.log(data.Code); 
									console.log(data.Msg); 
									if(data.Code=="000"){
										console.log(data.Msg)
										plus.nativeUI.toast("加班申请已提交");
									}else{
										plus.nativeUI.toast(data.Msg);
									} 
								},
								error:function(xhr,type,errorThrown){
									plus.nativeUI.toast("提交失败,错误原因:"+errorThrown);
									console.log(data.Msg);   
								}
								   
									  
					}); 
				});
			})
		</script>
	</body>
</html>
